<?php
/**
 * XuYuan Project
 *
 * @package	XueYuan 
 * @author	Jiuchi Team
 * @since	Version 1.0.0
 * @filesource
 */
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Login view
 * @author Wayne Yu
 */
?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>
    <?php $this->load->view('common/head');?>
	<!-- Page special css -->
    <link rel="stylesheet" type="text/css" href="/assets/css/index.css">
    <link rel="stylesheet" type="text/css" href="/assets/css/mycenter.css">
    <link rel="stylesheet" type="text/css" href="/assets/css/mycircle.css">
    <link rel="stylesheet" type="text/css" href="/assets/css/jquery.fancybox.css">
</head>
<body>
    <div class="navigation">
        <?php $this->load->view('common/navigation');?> 
    </div>
    <div class="wrapper">
		<div class="main-content">
			<div class="main-content-inner">
				<div class="home-list-title" style="font-weight: normal;color: #999;">
					<span class="pointer" onclick="window.location = '<?php echo site_url('topic/view/'.$commentInfo['topic_id'])?>'">&lt&lt&nbsp返回话题</span>
				</div>

				<div class="home-list">
					<div>
						<div id="topicDetails" class="clearfix">
							<ul id="replysMore">
								<li>
									<div class="rep">
										<div class="rep-header clearfix">
											<div style="width: 28px;height: 28px;background: black;position: absolute;margin-left: 5px;">
												<a href="<?php echo site_url('user/view/'.$userInfo['id'])?>">
	                                                	<img style="width:40px;" src="<?php echo $userInfo['headportrait']?>" class="img-avatar">
	                                                </a>
											</div>
											<div class="rep-note" style="line-height: 20px;">
												<i class="iconfont"></i>
												<span class="rep-auth-src" style="margin-left: 48px;"><a href="<?php echo site_url('user/view/'.$userInfo['id'])?>"><?php echo $userInfo['nickname']?></a></span>&nbsp<span class="rep-catalog text-small">的评论</span>
											</div>
											<div class="rep-time">2天前</div>
										</div>
										<div class="rep-content-wrapper clearfix">
											<div class="rep-content" style="position: relative;padding-top: 0px">
												<div class="rep-comment"><?php echo $commentInfo['content']?></div>
												<div class="add-reply pointer" style="position: absolute;right:10px;bottom:0px;color:#999;" onclick="showReply(this);">添加回复</div>  
											</div>
										</div>
										<div class="rep-rely hidden">
											<div class="reply-box" contenteditable="true"></div>
											<div class="clearfix">
												<button class="btn-reply btn-blue" onclick="publicReply(this)">发表</button>
												<span class="btn-cancel btn-write" onclick="hideReply(this)">取消</span>
											</div>
										</div>
									</div>
								</li>
								<li class="reply-item" style="padding-left: 30px;">
									<div class="rep bd-top">
										<div class="rep-header clearfix">
											<div class="headportrait" style="width: 28px;height: 28px;background: black;position: absolute;margin-left: 5px;">
											</div>
											<div class="rep-note" style="line-height: 20px;">
												<i class="iconfont"></i>
												<span class="rep-auth-src username cl-4c566c" style="margin-left: 48px;"></span>&nbsp<span class="rep-catalog text-small">回复了</span><span class="rep-auth-src replyname cl-4c566c" style="margin-left: 8px;"></span>
											</div>
											<div class="rep-time date"></div>
										</div>
										<div class="rep-content-wrapper clearfix">
											<div class="rep-content" style="position: relative;padding-top: 0px;">
												<div class="rep-comment content"></div>
												<div class="add-reply pointer" style="position: absolute;right:10px;bottom:0px;color:#999;" onclick="showReply(this);">回复</div> 
											</div>
										</div>                      
										<div class="rep-rely hidden">
											<div class="reply-box" contenteditable="true"></div>
											<div class="clearfix">
												<div class="hidden reply_user_id"></div>
												<button class="btn-reply btn-blue" onclick="publicReply(this)">发布</button>
												<span class="btn-cancel btn-write" onclick="hideReply(this)">取消</span>
											</div>
										</div>
									</div>
								</li>
								<a href="javascript:" class="btn-white btn-more">查看更多</a>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
    <div class="footer">
        <?php $this->load->view('common/footer');?>
    </div>
	<script type="text/javascript" src="/assets/js/jquery.more.js"></script>
    <script>
    $(document).ready(function() {
        $('#replysMore').more({
            'address': '<?php echo site_url('comment/getCommentReplies/'.$commentInfo['id'])?>',
            'template': '.reply-item',
            'trigger': '.btn-more'
        });
    });

    function showReply(ele) {
	    o = ele.parentNode.parentNode.nextSibling;
	    if(o.nodeType != 1) {
	    	o = o.nextSibling;
	    }
	    o.style.display='block';
    }

    function hideReply(ele) {
	    o = ele.parentNode.parentNode;
	    o.style.display='none';
    }

    function publicReply(ele) {
    	reply_user_id = ele.parentNode.firstChild;
    	if(reply_user_id.nodeType != 1) {
	    	reply_user_id = reply_user_id.nextSibling;
	    }
		content = ele.parentNode.parentNode.firstChild;
    	if(content.nodeType != 1) {
	    	content = content.nextSibling;
	    }
	    reply_user_id = reply_user_id.innerHTML;
	    content = content.innerHTML;
	    if(content.length < 1)
	    	return;
	    $.ajax({
            type: 'post',
            url: '<?php echo site_url('comment/createReplyPost')?>',
            data: {
            	comment_id : <?php echo $commentInfo['id']?>,
                reply_user_id : reply_user_id,
				content : content,          
            },
            dataType: 'json',
            success: function(data) {
                if (data.StatusCode == 200) {
                	alert('发表成功');
                	window.location.reload();
                } else if (data.StatusCode == 300) {
                	window.location.reload();
                }
            }
        });
    }
    </script>

</body>
</html>

